package com.jsz.peini.service.sms;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.jsz.peini.bean.sms.SmsLog;
import com.jsz.peini.common.constants.Constants;
import com.jsz.peini.mapper.sms.SmsLogMapper;
import com.jsz.peini.sms.SmsSend;

@Service
public class SmsService {
	
	@Resource
	private SmsLogMapper smsLogMapper;
	
	public int insertSms(SmsLog smsLog) {
		int result = smsLogMapper.insertSms(smsLog);
		return result;
	}
	
	public boolean sendMessage(String userName,String param,int smstype){
		boolean isSend = false;;
		String resultCode = SmsSend.sendMessage(userName,param,Constants.SMS_YZM);
		if(resultCode.equals("000000")){
			isSend = true;
		}
		SmsLog smsLog = new SmsLog();
		smsLog.setType(smstype);
		smsLog.setContent(param);
		smsLog.setPhone(userName);
		smsLog.setSmsStatus(resultCode);
		smsLogMapper.insertSms(smsLog);
		return isSend;
	}

}
